package com.dayuanit.dy15.atm.mapper;

import com.dayuanit.dy15.atm.entity.Card;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

public interface CardMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Card record);

    int insertSelective(Card record);

    Card selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Card record);

    int updateByPrimaryKey(Card record);

    Card getByCardNum(String cardNum);

    /**
     * 不要使用大而全的更新SQL语句，一定要将更新语句影响范围缩减到最小
     * @param cardId
     * @return
     */
    int updateBalance(@Param("cardId") Long cardId,
                      @Param("newBalance") Integer newBalance,
                      @Param("oldBalance") Integer oldBalance);

    Card getById4Lock(Long cardId);

    Card getById(Long cardId);

    Card getByNum4Lock(String cardNum);

    List<Card> listCardByUserId(Long userId);

    List<Card> listById(@Param("cardIds") Set cardIds);
}